Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat auth supported for clients #111

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

gutan
Copy link
Contributor

@gutan gutan commented Oct 29, 2019

proxy supported AUTH cmd for clients

@codecov-io
Copy link

Codecov Report

Merging #111 into master will decrease coverage by 0.19%.
The diff coverage is 44.64%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master     #111     +/-   ##
=========================================
- Coverage   49.47%   49.27%   -0.2%     
=========================================
  Files          62       62             
  Lines        6280     6307     +27     
=========================================
+ Hits         3107     3108      +1     
- Misses       2826     2849     +23     
- Partials      347      350      +3
Impacted Files Coverage Δ
proxy/config.go 25% <ø> (ø) ⬆️
proxy/proxy.go 0% <0%> (ø) ⬆️
proxy/handler.go 0% <0%> (ø) ⬆️
proxy/proto/redis/request.go 47.05% <0%> (-2.33%) ⬇️
proxy/proto/redis/cluster/proxy_conn.go 60.6% <0%> (ø) ⬆️
proxy/proto/redis/proxy_conn.go 72.63% <54.34%> (-8.81%) ⬇️
proxy/proto/pipe.go 82.64% <0%> (-0.83%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update eb1e8a6...fe617d5. Read the comment docs.

@@ -168,6 +169,13 @@ func (r *Request) IsSupport() bool {
return ok
}

func (r *Request) IsAuth() bool {
if r.IsCtl() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return r.IsCtrl() && bytes.Equal(r.resp.array[0].data, cmdAuthBytes)

} else if bytes.Equal(reqData, cmdQuitBytes) {
req.reply.respType = respString
// general supported cmd need authorized
if !pc.authorized && !req.IsAuth() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should not forward any command when pc.authorized is false. And so that authorized should be atomic flag or guard by mutex (be used by encoder/decoder together).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants